<?php include _include(APP_PATH.'view/htm/header.inc.htm');?>

<div class="row">
	<div class="col-lg-6 offset-lg-3">
		<div class="card card-block m-t-1">
			<h4 class="card-title">修改邮箱</h4>
			<form action="<?php echo url('my-name');?>" method="post" id="form">

				<p class="input-group">
					<span class="input-group-addon"><i class="icon icon-lock"></i></span>
					<input type="text" class="form-control" placeholder="新邮箱" name="username_new" id="username_new">
				</p>

				<p>
					<button type="submit" class="btn btn-primary btn-block" id="submit" data-loading-text="<?php echo lang('submiting');?>...">修改邮箱</button>
					<a role="button" class="btn btn-secondary center-block m-t-1" href="<?php echo url('my');?>"> <?php echo lang('back');?> </a>
				</p>
			</form>
		</div>
	</div>
</div>

<?php include _include(APP_PATH.'view/htm/footer.inc.htm');?>

<script>

var jform = $('#form');
var jsubmit = $('#submit');
jform.on('submit', function() {
	jform.reset();
	jsubmit.button('loading');
	var postdata = jform.serializeObject();
	postdata.username_new = postdata.username_new ;
	$.xpost(jform.attr('action'), postdata, function(code, message) {
		if(code == 0) {
			$.alert(message);
			jsubmit.button(message).delay(3000).button('reset');
			setTimeout("history.go(-1);location.reload()",3000);
		} else if(code < 0) {
			$.alert(message);
			jsubmit.button('reset');
		} else {
			jform.find('[name="'+code+'"]').alert(message).focus();
			jsubmit.button('reset');
		}
	});
	return false;
});
</script>